Warning: package 'tidyr' was built under R version 4.2.2
suppressPackageStartupMessages(library(stringr))
Warning: package 'stringr' was built under R version 4.2.2
A look into AFL player statistics 2017 - 2022
AFL_logos<-read.csv("AFL_logos.csv")# Replace these placeholders with your actual PostgreSQL credentialsdb_host <-"localhost"db_name <-"AFL_data"db_user <-"postgres"db_password <-"Cincinnati1"# Construct the connection stringcon_string <-paste0("host=", db_host," dbname=", db_name," user=", db_user," password=", db_password)# Establish the connectioncon <-dbConnect(RPostgres::Postgres(), dbname = db_name, user = db_user,password = db_password, host = db_host)# Years range (update this based on your data)start_year <-2017end_year <-2022# Create an empty list to store data framesdata_list <-list()# Loop through each yearfor (year in start_year:end_year) {# Generate the table name for the specific year table_name <-paste0("afl_player_season_stats_", year)# Fetch data from the table for the current year query <-paste0("SELECT * FROM ", table_name) data <-dbGetQuery(con, query)# Append the data to the list data_list[[year - start_year +1]] <- data}afl_player_stats <-do.call(rbind, data_list)# Loop through each yearfor (year in start_year:end_year) {# Generate the table name for the specific year table_name <-paste0("player_percentile_ranks_", year)# Fetch data from the table for the current year query <-paste0("SELECT * FROM ", table_name) data <-dbGetQuery(con, query)# Append the data to the list data_list[[year - start_year +1]] <- data}afl_player_percentiles <-do.call(rbind, data_list)player_details <-dbGetQuery(con,"SELECT * FROM afl_player_info")
Warning: Domain not specified, defaulting to observed range within each
specified column.
Warning: Since gt v0.9.0, the `colors` argument has been deprecated.
• Please use the `fn` argument instead.
This warning is displayed once every 8 hours.